﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YRevitJig;

namespace YArchitech.Plumbing
{
	public class RiserPipeLinesJig : XUiJigBase
	{
		public XYZ StartPoint { get; set; }

		public double Angle { get; set; }

		public double Distance { get; set; }

		public bool IsUseCustomAngle { get; set; }

		public RiserPipeLinesJig(UIDocument uiDoc, FrmMarkRiserpipe form) : base(uiDoc)
		{
			this.Angle = 45.0;
			this.Distance = 100.0;
			this.IsUseCustomAngle = false;
			this.formData = form;
			this.UpdateData();
		}

		public override void Draw(PaintEventArgs paintEventArgs)
		{
			base.Draw(paintEventArgs);
		}

		public override List<Curve> CreateCurves()
		{
			return new List<Curve>();
		}

		protected void UpdateData()
		{
			if (this.formData != null)
			{
				try
				{
					this.Angle = Convert.ToDouble(this.formData.textLineAngle.Text);
					this.Distance = Convert.ToDouble(this.formData.textDisToPipe.Text);
					this.IsUseCustomAngle = this.formData.checkLineAngle.Checked;
				}
				catch (Exception ex)
				{
					ex.ToString();
					this.Angle = 45.0;
					this.Distance = 800.0;
					this.IsUseCustomAngle = false;
				}
			}
		}

		protected double formatAngle(double angle)
		{
			int num = (int)(angle / Math.PI*2);
			double num2 = angle - (double)num * Math.PI*2;
			if (num2 < 0.0)
			{
				num2 += Math.PI*2;
			}
			return num2;
		}

		public List<Line> resultLines = new List<Line>();

		public const double _epsDouble = 1E-09;

		public FrmMarkRiserpipe formData;
	}
}
